import 'package:plugin_platform_interface/plugin_platform_interface.dart';

import 'stripe_terminal_usb_method_channel.dart';

abstract class StripeTerminalUsbPlatform extends PlatformInterface {
  /// Constructs a StripeTerminalUsbPlatform.
  StripeTerminalUsbPlatform() : super(token: _token);

  static final Object _token = Object();

  static StripeTerminalUsbPlatform _instance = MethodChannelStripeTerminalUsb();

  /// The default instance of [StripeTerminalUsbPlatform] to use.
  ///
  /// Defaults to [MethodChannelStripeTerminalUsb].
  static StripeTerminalUsbPlatform get instance => _instance;

  /// Platform-specific implementations should set this with their own
  /// platform-specific class that extends [StripeTerminalUsbPlatform] when
  /// they register themselves.
  static set instance(StripeTerminalUsbPlatform instance) {
    PlatformInterface.verifyToken(instance, _token);
    _instance = instance;
  }

  Future<String?> getPlatformVersion() {
    throw UnimplementedError('platformVersion() has not been implemented.');
  }

  /*
   * 获取权限
   */
  Future<bool> permissionAllowed() async{
    return await _instance.permissionAllowed();
  }
  /*
  初始化 并连接读卡器
   */
  Future<void> init(String localId,String tokenUrl,String departId)async{
    _instance.init(localId,tokenUrl,departId);
  }

  /*
  连接读卡器
   */
  Future<void> connectReaders()async{
    _instance.connectReaders();
  }
  /*
  打开钱箱
   */
  Future<bool> initOpenCash()async{
    return await _instance.initOpenCash();
  }
  /*
  打开钱箱
   */
  Future<Map> openCash()async{
    Map map = await _instance.openCash();
    return map;
  }

  /*
  支付
   */
  Future<Map> pay(String clientSecret)async{
    return await _instance.pay(clientSecret);
  }

  /*
  订单捕获
   */
  Future<Map> processPayment()async{
    return await _instance.processPayment();
  }

  /*
  取消等待刷卡状态
   */
  Future<bool> cancelRetrievePaymentIntent() async{
    return await instance.cancelRetrievePaymentIntent();
  }

  /*
  取消付款意向
   */
  Future<Map> cancelProcessPayment() async {
    Map map = await instance.cancelProcessPayment();
    return map;
  }


}
